<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <base href="<%=basePath%>">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <title>学习列表</title>
    <link rel="stylesheet" href="websrc/plug-in/hDialog/css/common.css"/>
    <link rel="stylesheet"
          href="websrc/bootstrap-3.3.7-dist/css/bootstrap.css">
    <link rel="stylesheet" href="websrc/css/common.css">
    <link rel="stylesheet" href="websrc/css/studyList.css">

    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <script src="websrc/js/jquery-3.2.1.js"></script>
    <script src="websrc/plug-in/hDialog/js/jquery.hDialog.js"></script>
    <script src="websrc/js/common.js"></script>
    <script>
        var beforeGotoStudy = function (id) {
            // /memorypalace/study/tostudy.action?studyListId=${sl.studyListId}
//			var id = $(dom).attr("id");
            var newCountId = id.replace("nameTag", "newCount");
            var newCount = $("#" + newCountId).val();
            var reviewCountId = id.replace("nameTag", "reviewCount");
            var reviewCount = $("#" + reviewCountId).val();
            var studyListId = $("#" + id).attr("name");
            if (newCount + reviewCount == 0) {
                // 没有要学习的卡片
                showTip("没有可学习的卡片", undefined, false);
            } else {
                window.location.href = "/memorypalace/study/tostudy.action?studyListId=" + studyListId;
            }
        // 加载新的个数
        };
        
       $.ajax({
	        'url': '/memorypalace/getuser.action',
	        'type': 'GET',
	        'success': function (userJSON) {
                //alert("一登陆");
                
                var userObj = JSON.parse(userJSON);
                var h = '<span style="padding-right:10px">'+userObj.userName+'</span>'+
    				'<a href="/memorypalace/loginout.action">退出</a>';
				$("#userUL").html(h);
	        },
	        'error':function (){
                //alert("未登录");
                var h = '<a href="login.jsp">登录</a>'+
				'<a href="register.jsp">注册</a>';
				$("#userUL").html(h);
	        }
	    });a 
    </script>

    <!--  <script>
        window.onload=function(){
            var deleteFlag=document.getElementById('deleteFlag');
            if(deleteFlag.value=='true'){
                alert('删除成功');
                window.opener.location.reload();
            }else if(deleteFlag.value=='false'){
                alert('删除失败');
            }

        };

        </script> -->

</head>

<body>
<div class="header clearfix">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed"
                        data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
                        aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span> <span
                        class="icon-bar"></span> <span class="icon-bar"></span> <span
                        class="icon-bar"></span>
                </button>
                <a class="navbar-brand header-left clearfix" href="#">
                    <div class="logo">LOGO</div>
                    <div class="projectName">记忆宫殿</div>
                    <div class="projectEnglishName">Memory Palace</div>
                </a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse"
                 id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="/memorypalace/index-login.html">个人首页</a></li>
                    <li class="active"><a href="/memorypalace/study/getsl.action">学习列表<span
                            class="sr-only">(current)</span></a></li>
                    <li><a href="/memorypalace/mydeck.html">浏览牌组</a></li>
                    <li><a href="/memorypalace/myknowledgetree.html">知识体系</a></li>


                </ul>

                <ul id="userUL" class="nav navbar-nav navbar-right" style="padding-top: 28px;padding-right: 10px">
					
				<!-- 	<c:if test="${users.userId==null}">
							<a href="login.jsp">登录</a>
							<a href="register.jsp">注册</a>
						</c:if>
					<c:if test="${users.userId!=null}">
						<span>${users.userName}</span>
						<a href="/memorypalace/loginout">退出</a>
					</c:if>			 -->
		
				</ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
</div>
<input type="hidden" id="deleteFlag" value="${deleteFlag}"/>
<div class="_studyList">
    <div class="_defaultList">
        <ul>
            <li class="_list">学习列表</li>
            <li class="_new">新的</li>
            <li class="_review">复习</li>
            <li class="_pull_down" style="margin-top: 23px;margin-left: 965px;">
                <%--<div class="_newbuild">--%>
                    <a href="/memorypalace/study/insertstudylist.html">
                        <button
                                type="button" class="btn btn-default">新 建
                        </button>
                    </a>
                <%--</div>--%>
            </li>
        </ul>
    </div>
    <c:forEach items="${listStudys}" var="sl" varStatus="i">
        <div class="_defaultList">
            <ul>
                <li class="_list1"><a id="nameTag${i.count}" name="${sl.studyListId}"
                                      href="javascript:beforeGotoStudy('nameTag${i.count}')">${sl.studyListName}</a>
                </li>
                <li class="_new_change" id="newCount${i.count}" value="${sl.newCard}"><p>${sl.newCard}</p></li>
                <li class="_review_change" id="reviewCount${i.count}" value="${sl.oldCard}"><p>${sl.oldCard}</p></li>
                <li class="_pull_down">
                    <div class="container" style="width: 95px">
                        <div class="row">
                            <div class="col-md-4">
                                <!-- 下拉 -->
                                <div class="dropdown">
                                    <a class="btn btn-default dropdown-toggle"
                                       data-toggle="dropdown"> 设置<span class="caret"></span>
                                    </a>
                                    <ul class="dropdown-menu">
                                        <li><a
                                                href="/memorypalace/study/editstudylist.html?studyListId=${sl.studyListId}">编辑</a>
                                        </li>
                                        <li><a
                                                href="javascript:if(confirm('是否删除')){window.location.replace('/memorypalace/study/deletesl.action?studyListId=${sl.studyListId}')}">删除</a>
                                        </li>
                                    </ul>

                                </div>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div style="border: 1px solid #f2dede;width: 1100px"></div>


    </c:forEach>

</div>

<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="websrc/js/bootstrap.min.js"></script>
</body>
</html>
